package com.intranet.fund.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.intranet.fund.dao.EmailDao;
import com.intranet.fund.domain.Email;
import com.water.dao.Page;

@Service
public class EmailService {

	@Autowired
	private EmailDao emailDao;

	public List<Email> getAllEmailByStatus(String status) {
		return emailDao.getAllEmailByStatus(status);
	}
	
	public Page getAllEmail(int pageNo, int pageSize, String param) {
		return emailDao.queryEmailList(pageNo, pageSize, param);
	}

	public String saveEmail(Email email) {
		String msg = "";
		try {
			emailDao.save(email);
			msg = "Y";
		} catch (RuntimeException e) {
			msg = e.toString();
		}
		return msg;
	}

	public String updateEmail(Email email) {
		String msg = "";
		try {
			emailDao.update(email);
			msg = "Y";
		} catch (RuntimeException e) {
			msg = e.toString();
		}
		return msg;
	}

	public String deleteEmail(Email email) {
		String msg = "";
		try {
			emailDao.remove(email);
			msg = "Y";
		} catch (RuntimeException e) {
			msg = "N";
		}
		return msg;
	}

	public Email getEmailById(Integer id) {
		return emailDao.get(id);
	}
}
